{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import polars as pl\n",
    "from buckaroo.buckaroo_widget import BuckarooWidget as PandasBuckarooWidget"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "df = pd.read_csv(\"/Users/paddy/code/example-notebooks/citibike-trips.csv\") #for airplane work\n",
    "pl_df = pl.read_csv(\"/Users/paddy/code/example-notebooks/citibike-trips.csv\") #for"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "%timeit PandasBuckarooWidget(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3",
   "metadata": {},
   "outputs": [],
   "source": [
    "%timeit PolarsBuckarooWidget(pl_df)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4",
   "metadata": {},
   "source": [
    "# At first glance the performance is close\n",
    "that looks like the performance is fairly close between polars and pandas\n",
    "\n",
    "I think I'm missing something"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5",
   "metadata": {},
   "outputs": [],
   "source": [
    "from buckaroo.dataflow import Sampling\n",
    "class FullSampling(Sampling):\n",
    "    pre_limit = False\n",
    "class FullPandasBuckarooWidget(PandasBuckarooWidget):\n",
    "    sampling_klass=FullSampling\n",
    "%timeit  FullPandasBuckarooWidget(df)\n",
    "bw = FullPandasBuckarooWidget(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6",
   "metadata": {},
   "outputs": [],
   "source": [
    "bw = FullPandasBuckarooWidget(df)\n",
    "len(bw.processed_df)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.read_parquet('banklist.parquet')\n",
    "print(len(df) * len(df.columns), len(df), len(df.columns))\n",
    "%timeit bw = BuckarooWidget(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9",
   "metadata": {},
   "outputs": [],
   "source": [
    "df2 = pd.read_csv('death-by-suicide-hispanic.csv')\n",
    "print(len(df2) * len(df2.columns), len(df2), len(df2.columns))\n",
    "%timeit bw = BuckarooWidget(df2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "10",
   "metadata": {},
   "outputs": [],
   "source": [
    "df10 = pd.read_csv('Machine_readable_file_bd_employ.csv')\n",
    "print(len(df10) * len(df10.columns), len(df10), len(df10.columns))\n",
    "%timeit bw = BuckarooWidget(df10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "11",
   "metadata": {},
   "outputs": [],
   "source": [
    "df9 = pd.read_csv('scorecard.csv')\n",
    "print(len(df9) * len(df9.columns), len(df9), len(df9.columns))\n",
    "%timeit bw = BuckarooWidget(df9)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "12",
   "metadata": {},
   "outputs": [],
   "source": [
    "df6 =  pd.read_parquet('1993-flights.gzip.parquet')\n",
    "print(len(df6) * len(df6.columns), len(df6), len(df6.columns))\n",
    "%timeit bw = BuckarooWidget(df6[:10_000])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "13",
   "metadata": {},
   "outputs": [],
   "source": [
    "df8 = pd.read_csv('train_extended.csv')\n",
    "print(len(df8) * len(df8.columns), len(df8), len(df8.columns))\n",
    "%timeit bw = BuckarooWidget(df8)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "14",
   "metadata": {},
   "outputs": [],
   "source": [
    "df4 = pd.read_csv('WPP2022_Demographic_Indicators_Medium.csv')\n",
    "print(len(df4) * len(df4.columns), len(df4), len(df4.columns))\n",
    "%timeit bw = BuckarooWidget(df4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "15",
   "metadata": {},
   "outputs": [],
   "source": [
    "df5 = pd.read_parquet('2014-01-citibike-trip-data.parquet')\n",
    "print(len(df5) * len(df5.columns), len(df5), len(df5.columns))\n",
    "%timeit bw = BuckarooWidget(df5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "16",
   "metadata": {},
   "outputs": [],
   "source": [
    "df3 = pd.read_parquet('Covid-data.gzip.parquet')\n",
    "print(len(df3) * len(df3.columns), len(df3), len(df3.columns))\n",
    "%timeit bw = BuckarooWidget(df3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "17",
   "metadata": {},
   "outputs": [],
   "source": [
    "%timeit bw = BuckarooWidget(df6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "18",
   "metadata": {},
   "outputs": [],
   "source": [
    "%prun -s cumtime "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
